#include "cute.h"
#include "ide_listener.h"
#include "cute_runner.h"
#include "SpellChecker.h"


void mainTestEng() {
	string filename1="text1.txt";
	string dict="eng";
	SpellChecker* sp = new SpellChecker(filename1,dict);
	sp->ReadFile(filename1,dict);
}

void mainTestPt() {
	string filename1="text2.txt";
	string dict="pt";
	SpellChecker* sp = new SpellChecker(filename1,dict);
	sp->ReadFile(filename1,dict);
}

void testMatcher() {
	string filename1="text1.txt";
	string dict="eng";
	SpellChecker* sp = new SpellChecker(filename1,dict);
	vector<string> dicWords;
	vector<option/*string*/> options;
	dicWords.push_back("sister");
	dicWords.push_back("vector");
	dicWords.push_back("element");
	dicWords.push_back("aa");
	dicWords.push_back("aaa");
	dicWords.push_back("aba");
	dicWords.push_back("act");
	char* toSearch = "elements";
	if(sp->approximateStringMatching(dicWords, toSearch, options)) cout << "Word is correct" << endl;
	cout << options.size() << endl;
	if(options.size() > 0 ) {
		cout << "Options: " << endl;
		for(unsigned int i=0; i<options.size(); i++ ){
			cout << options[i].opt << endl;
		}
	}
}

void testDict() {
	string filename1="text1.txt";
	string dict= "pt-PT.dic";//"en-US.dic";
	SpellChecker* sp = new SpellChecker(filename1,dict);
	vector<string> dicWords;
	sp->processDictionary(dict, dicWords);
	cout << "Dictionary size: " << dicWords.size() << endl;
	if(dicWords.size() > 0 ) {
		for(unsigned int i=24; i<50; i++ ){
			cout << dicWords[i] << endl;
		}
	}
}

void runSuite(){
	cute::suite s;
	//s.push_back(CUTE(testMatcher));
	//s.push_back(CUTE(testDict));
	s.push_back(CUTE(mainTestEng));
	//s.push_back(CUTE(mainTestPt));
	cute::ide_listener lis;
	cute::makeRunner(lis)(s, "The Suite");
}

int main(int argc, char *argv[]){

	//runSuite();
	string dict, filename1;

	if(argc == 1) {
		dict = "eng";
		filename1 = "text1.txt";
		//cout << "0 args. filename1 = " << filename1 << endl;
	}
	else if(argc == 2) {
		dict = "eng";
		filename1 = argv[1];
		//cout << "1 args. filename1 = " << filename1 << endl;
	}
	else {
		dict = argv[2];
		filename1 = argv[1];
		//cout << "2 args. filename1 = " << filename1 << endl;
	}

	SpellChecker* sp = new SpellChecker(filename1,dict);
	sp->ui();

    return 0;
}







